package com.nexus.all.manager;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nexus.all.dao.NoteLikeMapper;
import com.nexus.all.model.NoteLike;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class NoteLikeManager extends ServiceImpl<NoteLikeMapper, NoteLike> {

    public Boolean isLiked(Long likeDataId, Byte noteLikeType, Long userId) {
        LambdaQueryWrapper<NoteLike> wrapper = NoteLike.gw();
        wrapper.eq(NoteLike::getLikeDataId, likeDataId)
                .eq(NoteLike::getNoteLikeType, noteLikeType)
                .eq(NoteLike::getUserId, userId);
        return count(wrapper) > 0 ? Boolean.TRUE : Boolean.FALSE;
    }

    public List<NoteLike> isLiked(List<Long> likeDataIds, Byte noteLikeType, Long userId) {
        LambdaQueryWrapper<NoteLike> wrapper = NoteLike.gw();
        wrapper.in(NoteLike::getLikeDataId, likeDataIds);
        wrapper.eq(NoteLike::getNoteLikeType, noteLikeType);
        wrapper.eq(NoteLike::getUserId, userId);
        return list(wrapper);
    }
}
